/* eslint-disable no-console */
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { uniqueId } from 'lodash';
@Component({
  selector: 'app-header-grouping',
  templateUrl: './header-grouping.component.html',
  styles: [
    `
      .table-section > h3 {
        margin: 16px 0 8px 0;
      }
      .table-section lv-datatable {
        margin-bottom: 16px;
      }
      .aui-help-tips {
        margin-top: 16px;
      }
    `,
  ],
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class HeaderGroupingComponent implements OnInit {
  data;
  selection: [];
  constructor() {}

  ngOnInit(): void {
    this.initData();
  }

  initData(): void {
    this.data = Array.from({ length: 5 }).map((item, key) => this.initUser(key));
  }

  initUser(key: number): object {
    return {
      id: uniqueId('uid'),
      name: `this is long long long name of user${key}`,
      age: 10 + key,
      expand: false,
      number: `001100${key}`,
    };
  }

  checkAllChange(source): void {
    console.log('check all:', source);
  }

  selectionChange(source): void {
    console.log('selection change', source);
  }

  checkOneChange(source): void {
    console.log('check one', source);
  }
}
